import request from '@/utils/request'

const schedulerUrl = '/system/scheduler'

export function listJobByPage(data, page, size) {
  return request({
    url: `${schedulerUrl}/listJobByPage/` + page + '/' + size,
    method: 'post',
    data: data
  })
}

export function listLogByPage(data, page, size) {
  return request({
    url: `${schedulerUrl}/log/listLogByPage/` + page + '/' + size,
    method: 'post',
    data: data
  })
}

export function saveJob(data) {
  return request({
    url: `${schedulerUrl}/saveJob`,
    method: 'post',
    data: data
  })
}

export function updateJob(data) {
  return request({
    url: `${schedulerUrl}/updateJob`,
    method: 'put',
    data: data
  })
}

export function deleteJob(data) {
  return request({
    url: `${schedulerUrl}/deleteJob`,
    method: 'delete',
    data: data
  })
}

export function pauseJob(id) {
  return request({
    url: `${schedulerUrl}/pauseJob/` + id,
    method: 'put'
  })
}

export function resumeJob(id) {
  return request({
    url: `${schedulerUrl}/resumeJob/` + id,
    method: 'put'
  })
}

export function runJob(id) {
  return request({
    url: `${schedulerUrl}/runJob/` + id,
    method: 'put'
  })
}

export default {
  listJobByPage,
  saveJob,
  updateJob,
  deleteJob,
  pauseJob,
  resumeJob,
  runJob,
  listLogByPage
}
